home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacTech 1 to 12
/
MacTech-vol-1-12.toast
/
Tools
/
Alpha 6.51b13 ƒ
/
Tcl
/
UserCode
/
setBackupFolder.tcl
< prev
next >
Wrap
Text File
|
1996-08-15
|
4KB
|
148 lines
# FILE: setBackupFolder.tcl
#
# LAST UPDATE: 2/11/93 6:41:25 AM
# setBackupFolder = sets the backup folder based on location of file being
# edited. If folder named "$backName" is found relative to the file's location
# or relative to any folder above, then that is used. If no "$backName" folder
# is found, then turn off backupFolder. Thus the following hypothetical volume
# has respective backup files:
#
# HD
# :Backup:
# ::Addresses.bak
# :Lists:
# ::Addresses
# :Misc:
# ::Letters:
# :::Project RFQ
# ::Backup:
# :::Project RFQ.bak
# ::Memos:
# :::Backup:
# ::::Organization.bak
# :::Organization
# Floppy:
# :Readme
# :Readme.bak
#
# To use, source this file. It redefines activateHook & saveasHook,
# keeping the old definitions as original-activateHook & original-saveHook.
# A good place to source this is either from $HOME:AlphaBits.tcl (at the
# end) or $HOME:UserBits.tcl
# HISTORY
#
# modified who rev reason
# -------- --- --- ------
# 02/11/93 DCB 1.1 Now executes after loading to establish base folder
# 01/25/93 DCB 1.0 Original
################################################################################
# COPYRIGHT:
#
# Copyright © 1992,1993 by David C. Black All rights reserved.
# Portions copyright © 1990, 1991, 1992 Pete Keleher. All Rights Reserved.
#
# Redistribution and use in source and binary forms are permitted
# provided that the above copyright notice and this paragraph are
# duplicated in all such forms and that any documentation,
# advertising materials, and other materials related to such
# distribution and use acknowledge that the software was developed
# by David C. Black in conjunction with Pete Keleher.
#
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
################################################################################
# AUTHOR
#
# David C. Black
# Internet: black@mpd.tandem.com (preferred)
# GEnie: D.C.Black
# USnail: 6217 John Chisum Lane, Austin, TX 78749
#
################################################################################
set backupDir ":BackUp"
proc setBackupFolder {args} {
global backupDir
global backupFolder
global backupFolderName
if {[llength $args] > 0} {
set folder [lindex $args 0]
} else {
set wins [winNames -f]
if {[llength $wins] == 0} {
return
} else {
set folder [lindex $wins 0]
}
}
if {[regexp {^Untitled$} $folder]} {
return
}
regsub { <[0-9]+>$} $folder "" folder
if {[regexp {^[*].*[*]$} $folder]} {
# Ignore "*tcl shell*" and the like
return
}
while {[string first ":" $folder] >= 0} {
set folder [file dirname $folder]
if ([file isdirectory "$folder$backupDir"]) {
set backupFolderName "$folder$backupDir"
set backupFolder 1
# message $backupFolderName
return
}
}
append folder "$backupDir"
if ([file isdirectory "$folder"]) {
set backupFolderName "$folder"
set backupFolder 1
} else {
set backupFolder 0
}
# message $backupFolderName
}
#endproc setBackupFolder
if {[info procs setBackupFolder-saveasHook] != "setBackupFolder-saveasHook"} {
rename saveasHook setBackupFolder-saveasHook
proc saveasHook {oldName newName} {
setBackupFolder $newName
set result [eval setBackupFolder-saveasHook {$oldName} {$newName}]
return $result
}
#endproc saveasHook
rename activateHook setBackupFolder-activateHook
proc activateHook name {
setBackupFolder $name
set result [eval setBackupFolder-activateHook {$name}]
return $result
}
#endproc activateHook
rename openHook setBackupFolder-openHook
proc openHook name {
setBackupFolder $name
set result [eval setBackupFolder-openHook {$name}]
return $result
}
#endproc openHook
}
#endif
set wins [winNames -f]
if {[llength $wins]} {
activateHook [lindex $wins 0]
}